using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>

    public class LIST_GADGETInfo
    {
        #region Local Variable
        public enum Field
        {
            DTB,
            ID,
            Description,
            QDCode,
            ReportTmp,
            AutoUpdate,
            IsScroll,
            Action,
            Argument,
            Image,
            Param,
            IsDefault,
            ReportTmp_Print,
            Owner,
            Shared,
            DataGroup,
            Type
        }
        private String _DTB;
        private Int32 _ID;
        private String _Description;
        private String _QDCode;
        private String _ReportTmp;
        private Int32 _AutoUpdate;
        private Boolean _IsScroll;
        private String _Action;
        private String _Argument;
        private String _Image;
        private String _Param;
        private Boolean _IsDefault;
        private String _ReportTmp_Print;
        private String _Owner;
        private Boolean _Shared;
        private String _DataGroup;
        private String _Type;

        public String DTB { get { return _DTB; } set { _DTB = value; } }
        public Int32 ID { get { return _ID; } set { _ID = value; } }
        public String Description { get { return _Description; } set { _Description = value; } }
        public String QDCode { get { return _QDCode; } set { _QDCode = value; } }
        public String ReportTmp { get { return _ReportTmp; } set { _ReportTmp = value; } }
        public Int32 AutoUpdate { get { return _AutoUpdate; } set { _AutoUpdate = value; } }
        public Boolean IsScroll { get { return _IsScroll; } set { _IsScroll = value; } }
        public String Action { get { return _Action; } set { _Action = value; } }
        public String Argument { get { return _Argument; } set { _Argument = value; } }
        public String Image { get { return _Image; } set { _Image = value; } }
        public String Param { get { return _Param; } set { _Param = value; } }
        public Boolean IsDefault { get { return _IsDefault; } set { _IsDefault = value; } }
        public String ReportTmp_Print { get { return _ReportTmp_Print; } set { _ReportTmp_Print = value; } }
        public String Owner { get { return _Owner; } set { _Owner = value; } }
        public Boolean Shared { get { return _Shared; } set { _Shared = value; } }
        public String DataGroup { get { return _DataGroup; } set { _DataGroup = value; } }
        public String Type { get { return _Type; } set { _Type = value; } }

        #endregion LocalVariable

        #region Constructor
        public LIST_GADGETInfo()
        {
            _DTB = "";
            _ID = -1;
            _Description = "";
            _QDCode = "";
            _ReportTmp = "";
            _AutoUpdate = 0;
            _IsScroll = true;
            _Action = "";
            _Argument = "";
            _Image = "";
            _Param = "";
            _IsDefault = true;
            _ReportTmp_Print = "";
            _Owner = "";
            _Shared = true;
            _DataGroup = "";
            _Type = "";
        }
        public LIST_GADGETInfo(
        String DTB,
        Int32 ID,
        String Description,
        String QDCode,
        String ReportTmp,
        Int32 AutoUpdate,
        Boolean IsScroll,
        String Action,
        String Argument,
        String Image,
        String Param,
        Boolean IsDefault,
        String ReportTmp_Print,
        String Owner,
            Boolean Shared,
            String DataGroup,
            String Type
        )
        {
            _DTB = DTB;
            _ID = ID;
            _Description = Description;
            _QDCode = QDCode;
            _ReportTmp = ReportTmp;
            _AutoUpdate = AutoUpdate;
            _IsScroll = IsScroll;
            _Action = Action;
            _Argument = Argument;
            _Image = Image;
            _Param = Param;
            _IsDefault = IsDefault;
            _ReportTmp_Print = ReportTmp_Print;
            _Owner = Owner;
            _Shared = Shared;
            _DataGroup = DataGroup;
            _Type = Type;
        }
        public LIST_GADGETInfo(DataRow dr)
        {
            if (dr != null)
            {
                _DTB = dr[Field.DTB.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.DTB.ToString()]);
                _ID = dr[Field.ID.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.ID.ToString()]);
                _Description = dr[Field.Description.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Description.ToString()]);
                _QDCode = dr[Field.QDCode.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.QDCode.ToString()]);
                _ReportTmp = dr[Field.ReportTmp.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.ReportTmp.ToString()]);
                _AutoUpdate = dr[Field.AutoUpdate.ToString()] == DBNull.Value ? 0 : Convert.ToInt32(dr[Field.AutoUpdate.ToString()]);
                _IsScroll = dr[Field.IsScroll.ToString()] == DBNull.Value ? true : Convert.ToBoolean(dr[Field.IsScroll.ToString()]);
                _Action = dr[Field.Action.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Action.ToString()]);
                _Argument = dr[Field.Argument.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Argument.ToString()]);
                _Image = dr[Field.Image.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Image.ToString()]);
                _Param = dr[Field.Param.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Param.ToString()]);
                _IsDefault = dr[Field.IsDefault.ToString()] == DBNull.Value ? true : Convert.ToBoolean(dr[Field.IsDefault.ToString()]);
                _ReportTmp_Print = dr[Field.ReportTmp_Print.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.ReportTmp_Print.ToString()]);
                _Owner = dr[Field.Owner.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Owner.ToString()]);
                _Shared = dr[Field.Shared.ToString()] == DBNull.Value ? true : Convert.ToBoolean(dr[Field.Shared.ToString()]);
                _DataGroup = dr[Field.DataGroup.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.DataGroup.ToString()]);
                _Type = dr[Field.Type.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.Type.ToString()]);
            }
        }
        public LIST_GADGETInfo(LIST_GADGETInfo objEntr)
        {
            _DTB = objEntr.DTB;
            _ID = objEntr.ID;
            _Description = objEntr.Description;
            _QDCode = objEntr.QDCode;
            _ReportTmp = objEntr.ReportTmp;
            _AutoUpdate = objEntr.AutoUpdate;
            _IsScroll = objEntr.IsScroll;
            _Action = objEntr.Action;
            _Argument = objEntr.Argument;
            _Image = objEntr.Image;
            _Param = objEntr.Param;
            _IsDefault = objEntr.IsDefault;
            _ReportTmp_Print = objEntr.ReportTmp_Print;
            _Owner = objEntr.Owner;
            _Shared = objEntr.Shared;
            _DataGroup = objEntr.DataGroup;
            _Type = objEntr.Type;
        }
        #endregion Constructor

        #region InitTable
        public static DataTable ToDataTable()
        {
            DataTable dt = new DataTable("LIST_GADGET");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Description.ToString(), typeof(String)),
				new DataColumn(Field.QDCode.ToString(), typeof(String)),
				new DataColumn(Field.ReportTmp.ToString(), typeof(String)),
				new DataColumn(Field.AutoUpdate.ToString(), typeof(Int32)),
				new DataColumn(Field.IsScroll.ToString(), typeof(Boolean)),
				new DataColumn(Field.Action.ToString(), typeof(String)),
				new DataColumn(Field.Argument.ToString(), typeof(String)),
				new DataColumn(Field.Image.ToString(), typeof(String)),
				new DataColumn(Field.Param.ToString(), typeof(String)),
				new DataColumn(Field.IsDefault.ToString(), typeof(Boolean)),
				new DataColumn(Field.ReportTmp_Print.ToString(), typeof(String)),
				new DataColumn(Field.Owner.ToString(), typeof(String)),
                new DataColumn(Field.Shared.ToString(), typeof(Boolean)),
                new DataColumn(Field.DataGroup.ToString(), typeof(String)),
                new DataColumn(Field.Type.ToString(), typeof(String)),
			});
            return dt;
        }
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.DTB.ToString()] = _DTB;
            row[Field.ID.ToString()] = _ID;
            row[Field.Description.ToString()] = _Description;
            row[Field.QDCode.ToString()] = _QDCode;
            row[Field.ReportTmp.ToString()] = _ReportTmp;
            row[Field.AutoUpdate.ToString()] = _AutoUpdate;
            row[Field.IsScroll.ToString()] = _IsScroll;
            row[Field.Action.ToString()] = _Action;
            row[Field.Argument.ToString()] = _Argument;
            row[Field.Image.ToString()] = _Image;
            row[Field.Param.ToString()] = _Param;
            row[Field.IsDefault.ToString()] = _IsDefault;
            row[Field.ReportTmp_Print.ToString()] = _ReportTmp_Print;
            row[Field.Owner.ToString()] = _Owner;
            row[Field.Shared.ToString()] = _Shared;
            row[Field.DataGroup.ToString()] = _DataGroup;
            row[Field.Type.ToString()] = _Type;
            return row;
        }
        #endregion InitTable
    }
}
